/**
 * 
 */
package org.t2.backstage.module.gameserver.service;

import java.util.List;

import org.banish.sql.core.util.QuerySet;
import org.gaming.backstage.PageData;
import org.gaming.service.service.AbstractService;
import org.springframework.stereotype.Service;
import org.t2.backstage.module.gameserver.model.GameDb;

/**
 * @author YY
 *
 */
@Service
public class GameDbService extends AbstractService<GameDb> {

	public List<GameDb> dbs(int platformId, int serverId, String type) {
		QuerySet querySet = new QuerySet();
		querySet.addCondition("platform_id = ?", platformId);
		querySet.addCondition("server_id = ?", serverId);
		querySet.addCondition("type = ?", type);
		querySet.formWhere();
		return this.repository().getBaseDao().queryListWhere(querySet.getWhere(), querySet.getParams());
	}
	
	public GameDb getDb(String dbName) {
		return this.repository().getByKeys(dbName);
	}
	
	public List<GameDb> getDbs() {
		return this.repository().getAll();
	}

	@Override
	public void mergeServer(int mergeDbZoneId) {
		//不必理会
	}
	
	public PageData<GameDb> query(QuerySet querySet) {
		querySet.formWhere();
		List<GameDb> result = this.repository().getBaseDao().queryListWhere(querySet.getWhere(), querySet.getParams());
		long count = repository().getBaseDao().countWhere(querySet.getCountWhere(), querySet.getCountParams());
		PageData<GameDb> queryPage = new PageData<>(count, result);
		return queryPage;
	}
}
